#pragma once
#include "SDL.h"

class SDLInput
{
#pragma region SINGLETON
public:
	static SDLInput* GetInstance()
	{
		if(instance == nullptr)
		{
			instance = new SDLInput();
		}
		return instance;
	}
	static void Kill()
	{
		delete instance;
		instance = nullptr;
	}
private:
	static SDLInput* instance;

	SDLInput();
	SDLInput(const SDLInput& r);
	~SDLInput(){}

	SDLInput& operator=(const SDLInput& r);
#pragma endregion
public:
	void Poll(SDL_Event e);
	bool IsKeyHeld(SDL_Scancode key);
	bool IsKeyPressed(SDL_Scancode key);
	bool IsKeyReleased(SDL_Scancode key);

	bool IsMouseButtonHeld(int button);
	bool IsMouseButtonPressed(int button);
	bool IsMouseButtonReleased(int button);
	void GetMousePosition(int& x, int& y);

private:

	static const int KEY_COUNT = 256;
	static const int MOUSE_BUTTON_COUNT = 5;

	bool keys[KEY_COUNT];
	bool lastKeys[KEY_COUNT];

	bool mouseButtons[MOUSE_BUTTON_COUNT];
	bool lastMouseButtons[MOUSE_BUTTON_COUNT];
	int mouseX, mouseY;
};

